//2009/08/23 02:40:03
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class SearchBox
{
public:
    int find(string text, string search, string wholeWord, int start)
    {
        string s = text;
        for (int i=start; i<s.size(); i++)
        {
            string temp = s.substr(i);
            size_t pos = temp.find(search);
            if (pos == string::npos) break;
            i += pos;
            if (wholeWord == "N") return i ;
            else if ((i == 0 || s[i-1]==' ') && (i+search.size()==s.size() || s[i+search.size()] == ' '))
                return i;
            i++;
        }
        return -1;
    }
};
